package com.jgy.策略模式_注解版;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.math.BigDecimal;
import java.util.Map;

/**
 * @author 姜光远
 * @date 2023/11/18 11:52
 */
@RestController
public class StrategyController {

    //将Strategy所有的实现类bean对象放到map中，key为bean的name
    @Autowired
    private Map<String, Strategy> stringStrategyMap;

    @GetMapping("calculate")
    public void calculate(BigDecimal money){
        stringStrategyMap.forEach((k,v)->{
            System.out.println(k+v.calculateTaks());
        });
    }


}
